﻿using Md.Api.Model;
using Md.Api.Model.Manage.MdBanner.Request;
using Md.Api.Service.Manage.MdBanner;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 轮播图
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/md/banner")]
public class MdBannerController : ControllerBase
{
    /// <summary>
    /// 通过编号删除轮播图服务
    /// </summary>
    public DeleteMdBannerByIdService deleteMdBannerByIdService { get; set; }
    /// <summary>
    /// 通过编号删除轮播图
    /// </summary>
    /// <param name="bannerIds">轮播图编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{bannerIds}")]
    public async Task<ResponseMessageModel> DeleteMdBannerById(string bannerIds, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteMdBannerByIdModel();

        model.Ids = bannerIds;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteMdBannerByIdService.Execute(model));
    }

    /// <summary>
    /// 添加轮播图服务
    /// </summary>
    public InsertMdBannerService insertMdBannerService { get; set; }
    /// <summary>
    /// 添加轮播图
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertMdBanner([FromBody] RequestInsertMdBannerModel model)
    {
        return await Task.Run(() => insertMdBannerService.Execute(model));
    }

    /// <summary>
    /// 通过编号更新轮播图服务
    /// </summary>
    public UpdateMdBannerByIdService updateMdBannerByIdService { get; set; }
    /// <summary>
    /// 通过编号更新轮播图
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateMdBannerById([FromBody] RequestUpdateMdBannerByIdModel model)
    {
        return await Task.Run(() => updateMdBannerByIdService.Execute(model));
    }

    /// <summary>
    /// 通过编号获取轮播图服务
    /// </summary>
    public GetMdBannerByIdService getMdBannerByIdService { get; set; }
    /// <summary>
    /// 通过编号获取轮播图
    /// </summary>
    /// <param name="bannerId">轮播图编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{bannerId}")]
    public async Task<ResponseMessageModel> GetMdBannerById(long bannerId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetMdBannerByIdModel();

        model.BannerId = bannerId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getMdBannerByIdService.Execute(model));
    }

    /// <summary>
    /// 获取轮播图列表服务
    /// </summary>
    public GetMdBannerListService getMdBannerListService { get; set; }
    /// <summary>
    /// 获取轮播图列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetMdBannerList([FromBody] RequestGetMdBannerListModel model)
    {
        return await Task.Run(() => getMdBannerListService.Execute(model));
    }

    /// <summary>
    /// 分页获取轮播图列表服务
    /// </summary>
    public GetMdBannerPageListService getMdBannerPageListService { get; set; }
    /// <summary>
    /// 分页获取轮播图列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetMdBannerPageList([FromBody] RequestGetMdBannerPageListModel model)
    {
        return await Task.Run(() => getMdBannerPageListService.Execute(model));
    }
}

